package mobile.TheOldRepublic.util;

import java.io.File;
import java.io.IOException;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Environment;
import android.util.Log;

public class Utils {
	
	public static final String APPLICATION_PATH = "ittr";
	
	public static File getAppDirectory() throws IOException
	{
		File outputDir = new File(Environment.getExternalStorageDirectory(), APPLICATION_PATH);
		if(outputDir.isDirectory())
			return outputDir;
		
//		if(outputDir.canWrite())
		outputDir.mkdir();
		
		if(! outputDir.isDirectory())
			throw new IOException("Could not create application directory.");
		
//		Log.d(Utils.getClass().getSimpleName(), "Using output directory "+outputDir);
		return outputDir;
	}

	public static void showSimpleDialog(Context context, String title, String message){
		AlertDialog.Builder alert = new AlertDialog.Builder(context);
		alert.setTitle(title);
		alert.setMessage(message);
		alert.setPositiveButton("Ok", new DialogInterface.OnClickListener(){
			@Override
			public void onClick(DialogInterface dialog, int whichButton){}
		});
		AlertDialog ad = alert.create();
		ad.show();
	}
}
